package com.ihr360.payroll.service.salarytasklet;

import com.ihr360.job.core.entity.JobInstance;
import com.ihr360.job.core.repository.JobExecutionAlreadyRunningException;
import com.ihr360.tasklet.JobExecutionOverview;

import java.util.List;

/**
 * 薪资计算任务业务实现
 * @author davidwei
 */
public interface SalaryTaskletService {
    /**
     * 开始一个新的核算任务,在进行此人无之前保证账期和批次已经创建
     *
     * @param salaryPlanId 薪资方案id
     * @param periodId     账期id
     * @param termId       批次id
     * @param staffIdList  需要处理的员工id
     * @param year         账期年
     * @param month        账期月
     * @param seq  执行序列号
     * @return 返回唯一表示一个任务的key
     * @throws JobExecutionAlreadyRunningException 任务正在执行中
     */
    JobExecutionOverview launchPreDataAndCalcJob(Long salaryPlanId, Long periodId, Long termId, List<String> staffIdList,
                                                 Integer year, Integer month, int seq) throws JobExecutionAlreadyRunningException;

    /**
     * 只取数不计算
     *
     * @param salaryPlanId
     * @param periodId
     * @param termId
     * @param staffIdList
     * @param year
     * @param month
     * @param seq
     * @return
     * @throws JobExecutionAlreadyRunningException 任务正在执行中
     */
    JobExecutionOverview launchPreDataJob(Long salaryPlanId, Long periodId, Long termId, List<String> staffIdList,
                                          Integer year, Integer month, int seq) throws JobExecutionAlreadyRunningException;

    /**
     * 利用之前的取数直接计算
     *
     * @param salaryPlanId
     * @param periodId
     * @param termId
     * @param staffIdList
     * @param year
     * @param month
     * @param seq
     * @return
     * @throws JobExecutionAlreadyRunningException 任务正在执行中
     */
    JobExecutionOverview launchCalcJob(Long salaryPlanId, Long periodId, Long termId, List<String> staffIdList,
                                       Integer year, Integer month, int seq) throws JobExecutionAlreadyRunningException;

    /**
     * 强制重启任务
     * @param salaryPlanId
     * @param periodId
     * @param termId
     * @param year
     * @param month
     * @param seq
     * @return
     */
    JobInstance forceRestartJob(Long salaryPlanId, Long periodId, Long termId, Integer year, Integer month, int seq);
}